<?php
/**
 * Created By base
 * Author: Virus
 * Date: 2020/3/11
 * Time: 12:48
 */

namespace app\common\model\mysql;


use think\Model;

class BaseModel extends Model
{
    protected $autoWriteTimestamp = true;

    public function getLists($param = [])
    {
        $where = [];
        // 判断状态
        if (isset($param['status']) && $param['status'] > -1) {
            $where[] = ['status', '=', $param['status']];
        }
        $field = isset($param['field']) ? $param['field'] : "";
        $order = isset($param['order']) ? $param['order'] : "id desc";

        return $this->where($where)->field($field)->order($order)->select();
    }

    /**
     * @param $id
     * @return bool
     */
    public function findOne($id)
    {
        $id = intval($id);
        if (empty($id)) {
            return false;
        }

        return $this->find($id)->getData();
    }
}